package com.ljr.v2;

import com.google.common.base.Strings;
import lombok.var;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @description: 接口指标收集器
 * @author: lijunrong
 * @create: 2022/1/18 7:12 PM
 */
public class MetricsCollector {

    private MetricsStorage metricsStorage;

    private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);

    /**
     * 进行接口性能数据记录
     */
    public void recordResponse(RequestInfo requestInfo){
        if(requestInfo == null || Strings.isNullOrEmpty(requestInfo.getApiKey()));
        executor.execute(() -> metricsStorage.saveRequestInfo(requestInfo));
    }

}
